From 660f8ae4a3869129ed0a35b83a8a87ef2c042fdf Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 16 Dec 2023 22:14:06 +0000 Subject: Garbage collect on function exit --- ...mpiler.testing.snapshots.Snapshotter)].expected | 30 +++++++++++++++++++++- ...mpiler.testing.snapshots.Snapshotter)].expected | 30 +++++++++++++++++++++- ...mpiler.testing.snapshots.Snapshotter)].expected | 30 +++++++++++++++++++++- ...mpiler.testing.snapshots.Snapshotter)].expected | 30 +++++++++++++++++++++- ...mpiler.testing.snapshots.Snapshotter)].expected | 30 +++++++++++++++++++++- ...mpiler.testing.snapshots.Snapshotter)].expected | 30 +++++++++++++++++++++- 6 files changed, 174 insertions(+), 6 deletions(-) (limited to 'snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]') diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:canCaptureFreeVariablesThatAreSetAfterDefinition(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:canCaptureFreeVariablesThatAreSetAfterDefinition(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index c6d0cf8a..2d07d2bb 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:canCaptureFreeVariablesThatAreSetAfterDefinition(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:canCaptureFreeVariablesThatAreSetAfterDefinition(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -1,10 +1,34 @@ Compilation unit elements: +( + function-decl + "shed__runtime__gc_get_root_stack_index" + params=() + return-type=int +) +( + function-decl + "shed__runtime__gc_set_root_stack_index" + params=((param "gc_root_stack_index" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_push_root" + params=((param "gc_root" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_collect" + params=() + return-type=void +) ( function "shed__function__f__0" visibility=private - locals=((param "closurePointer__0" data-ptr) (val "local__a" int) (val "local__b" int)) + locals=((param "closurePointer__0" data-ptr) (val "local__a" int) (val "local__b" int) (val "gcRootStackIndex__0" int)) return-type=int body=( ( @@ -21,6 +45,10 @@ Compilation unit elements: layout=(struct ((struct (data-ptr int int int)) (struct (function-ptr (struct ()) (struct (int int)))))) offset=(1 2 1) ) + (call (local "gcRootStackIndex__0") "shed__runtime__gc_get_root_stack_index" ()) + (call _ "shed__runtime__gc_set_root_stack_index" ((local "gcRootStackIndex__0"))) + (call _ "shed__runtime__gc_push_root" ((local "local__a"))) + (call _ "shed__runtime__gc_collect" ()) (return (local "local__a")) ) ) diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:canDefineMinimalFunction(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:canDefineMinimalFunction(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index 65d67506..01828098 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:canDefineMinimalFunction(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:canDefineMinimalFunction(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -1,13 +1,41 @@ Compilation unit elements: +( + function-decl + "shed__runtime__gc_get_root_stack_index" + params=() + return-type=int +) +( + function-decl + "shed__runtime__gc_set_root_stack_index" + params=((param "gc_root_stack_index" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_push_root" + params=((param "gc_root" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_collect" + params=() + return-type=void +) ( function "shed__function__f__0" visibility=private - locals=((param "closurePointer__0" data-ptr) (val "tmp__0" int)) + locals=((param "closurePointer__0" data-ptr) (val "gcRootStackIndex__0" int) (val "tmp__0" int)) return-type=int body=( + (call (local "gcRootStackIndex__0") "shed__runtime__gc_get_root_stack_index" ()) (local-store (local "tmp__0") (int 0)) + (call _ "shed__runtime__gc_set_root_stack_index" ((local "gcRootStackIndex__0"))) + (call _ "shed__runtime__gc_push_root" ((local "tmp__0"))) + (call _ "shed__runtime__gc_collect" ()) (return (local "tmp__0")) ) ) diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:effectHandlerMethodSwapsEffectHandlerInBody(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:effectHandlerMethodSwapsEffectHandlerInBody(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index f764af61..040ae764 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:effectHandlerMethodSwapsEffectHandlerInBody(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:effectHandlerMethodSwapsEffectHandlerInBody(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -12,13 +12,38 @@ Compilation unit elements: params=((param "effectHandler" data-ptr)) return-type=void ) +( + function-decl + "shed__runtime__gc_get_root_stack_index" + params=() + return-type=int +) +( + function-decl + "shed__runtime__gc_set_root_stack_index" + params=((param "gc_root_stack_index" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_push_root" + params=((param "gc_root" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_collect" + params=() + return-type=void +) ( function "shed__effectHandlerMethod__f__0" visibility=private - locals=((param "closurePointer__0" data-ptr) (val "effectHandler__0" data-ptr) (val "effectHandler__1" data-ptr) (val "tmp__0" int)) + locals=((param "closurePointer__0" data-ptr) (val "gcRootStackIndex__0" int) (val "effectHandler__0" data-ptr) (val "effectHandler__1" data-ptr) (val "tmp__0" int)) return-type=int body=( + (call (local "gcRootStackIndex__0") "shed__runtime__gc_get_root_stack_index" ()) (call (local "effectHandler__0") "shed__runtime__effects_get_handler" ()) ( memory-load @@ -29,6 +54,9 @@ Compilation unit elements: ) (call _ "shed__runtime__effects_set_handler" ((local "effectHandler__1"))) (local-store (local "tmp__0") (int 0)) + (call _ "shed__runtime__gc_set_root_stack_index" ((local "gcRootStackIndex__0"))) + (call _ "shed__runtime__gc_push_root" ((local "tmp__0"))) + (call _ "shed__runtime__gc_collect" ()) (call _ "shed__runtime__effects_set_handler" ((local "effectHandler__0"))) (resume (local "tmp__0")) ) diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:immutableFreeVariablesAreStoredInAndLoadedFromEnvironment(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:immutableFreeVariablesAreStoredInAndLoadedFromEnvironment(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index a528eb05..35b32735 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:immutableFreeVariablesAreStoredInAndLoadedFromEnvironment(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:immutableFreeVariablesAreStoredInAndLoadedFromEnvironment(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -1,10 +1,34 @@ Compilation unit elements: +( + function-decl + "shed__runtime__gc_get_root_stack_index" + params=() + return-type=int +) +( + function-decl + "shed__runtime__gc_set_root_stack_index" + params=((param "gc_root_stack_index" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_push_root" + params=((param "gc_root" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_collect" + params=() + return-type=void +) ( function "shed__function__f__0" visibility=private - locals=((param "closurePointer__0" data-ptr) (val "local__a" int) (val "local__b" int)) + locals=((param "closurePointer__0" data-ptr) (val "local__a" int) (val "local__b" int) (val "gcRootStackIndex__0" int)) return-type=int body=( ( @@ -21,6 +45,10 @@ Compilation unit elements: layout=(struct ((struct (data-ptr int int int)) (struct (function-ptr (struct ()) (struct (int int)))))) offset=(1 2 1) ) + (call (local "gcRootStackIndex__0") "shed__runtime__gc_get_root_stack_index" ()) + (call _ "shed__runtime__gc_set_root_stack_index" ((local "gcRootStackIndex__0"))) + (call _ "shed__runtime__gc_push_root" ((local "local__a"))) + (call _ "shed__runtime__gc_collect" ()) (return (local "local__a")) ) ) diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:pointersToFreeMutableVariablesAreStoredInAndLoadedFromEnvironment(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:pointersToFreeMutableVariablesAreStoredInAndLoadedFromEnvironment(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index 70ee5036..8f0b9f0f 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:pointersToFreeMutableVariablesAreStoredInAndLoadedFromEnvironment(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:pointersToFreeMutableVariablesAreStoredInAndLoadedFromEnvironment(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -1,10 +1,34 @@ Compilation unit elements: +( + function-decl + "shed__runtime__gc_get_root_stack_index" + params=() + return-type=int +) +( + function-decl + "shed__runtime__gc_set_root_stack_index" + params=((param "gc_root_stack_index" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_push_root" + params=((param "gc_root" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_collect" + params=() + return-type=void +) ( function "shed__function__f__0" visibility=private - locals=((param "closurePointer__0" data-ptr) (val "local__a" data-ptr) (val "local__b" data-ptr)) + locals=((param "closurePointer__0" data-ptr) (val "local__a" data-ptr) (val "local__b" data-ptr) (val "gcRootStackIndex__0" int)) return-type=int body=( ( @@ -21,6 +45,10 @@ Compilation unit elements: layout=(struct ((struct (data-ptr int int int)) (struct (function-ptr (struct ()) (struct (data-ptr data-ptr)))))) offset=(1 2 1) ) + (call (local "gcRootStackIndex__0") "shed__runtime__gc_get_root_stack_index" ()) + (call _ "shed__runtime__gc_set_root_stack_index" ((local "gcRootStackIndex__0"))) + (call _ "shed__runtime__gc_push_root" ((local "local__a"))) + (call _ "shed__runtime__gc_collect" ()) (return (local "local__a")) ) ) diff --git a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:positionalAndNamedParamsAreDefined(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:positionalAndNamedParamsAreDefined(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected index bda47107..ba98ae45 100644 --- a/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:positionalAndNamedParamsAreDefined(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected +++ b/snapshots/[engine:junit-jupiter]/[class:org.shedlang.compiler.patio.PatioCodeGenDefineFunctionTests]/[method:positionalAndNamedParamsAreDefined(org.shedlang.compiler.testing.snapshots.Snapshotter)].expected @@ -1,16 +1,40 @@ Compilation unit elements: +( + function-decl + "shed__runtime__gc_get_root_stack_index" + params=() + return-type=int +) ( function-decl "shed__runtime__int_add" params=((param "left" int) (param "right" int)) return-type=int ) +( + function-decl + "shed__runtime__gc_set_root_stack_index" + params=((param "gc_root_stack_index" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_push_root" + params=((param "gc_root" int)) + return-type=void +) +( + function-decl + "shed__runtime__gc_collect" + params=() + return-type=void +) ( function "shed__function__f__0" visibility=private - locals=((param "closurePointer__0" data-ptr) (param "local__param1" int) (param "local__param2" int) (param "local__paramA" int) (param "local__paramB" int) (param "local__paramC" int) (val "local__a" int) (val "local__b" int) (val "binaryOpResult__0" int) (val "binaryOpResult__1" int)) + locals=((param "closurePointer__0" data-ptr) (param "local__param1" int) (param "local__param2" int) (param "local__paramA" int) (param "local__paramB" int) (param "local__paramC" int) (val "local__a" int) (val "local__b" int) (val "gcRootStackIndex__0" int) (val "binaryOpResult__0" int) (val "binaryOpResult__1" int)) return-type=int body=( ( @@ -27,8 +51,12 @@ Compilation unit elements: layout=(struct ((struct (data-ptr int int int)) (struct (function-ptr (struct ()) (struct (int int)))))) offset=(1 2 1) ) + (call (local "gcRootStackIndex__0") "shed__runtime__gc_get_root_stack_index" ()) (call (local "binaryOpResult__0") "shed__runtime__int_add" ((local "local__a") (local "local__param1"))) (call (local "binaryOpResult__1") "shed__runtime__int_add" ((local "binaryOpResult__0") (local "local__paramA"))) + (call _ "shed__runtime__gc_set_root_stack_index" ((local "gcRootStackIndex__0"))) + (call _ "shed__runtime__gc_push_root" ((local "binaryOpResult__1"))) + (call _ "shed__runtime__gc_collect" ()) (return (local "binaryOpResult__1")) ) ) -- cgit v1.2.3